package com.zjl;

import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.net.URL;

public class BaseTest {
    public AndroidDriver driver=null;
    String urlStr="http://127.0.0.1:4723/wd/hub";
    @BeforeClass
    public void setUp()throws Exception{
        URL url=new URL(urlStr);
        DesiredCapabilities cap=new DesiredCapabilities();
        cap.setCapability("platformName","Android");
        cap.setCapability("appium:deviceName","127.0.0.1:62001");
        cap.setCapability("appium:appPackage","com.example.petwithlove");
        cap.setCapability("appium:appActivity",".login.PasswordLogin");
        driver=new AndroidDriver(url,cap);

    }
    @AfterClass
    public void quit()throws Exception{
        if(driver!=null){
            driver.quit();
        }
    }
//    @Test(priority = 0)
//    public void test_login() throws Exception{
//        Thread.sleep(2000);
//        WebElement element1 = driver.findElement(By.id("com.example.petwithlove:id/psw_login_tele"));
//        element1.click();
//        element1.sendKeys("18332299702");
//        WebElement element2 = driver.findElement(By.id("com.example.petwithlove:id/login_password"));
//        element2.click();
//        element2.sendKeys("123456");
//        driver.findElement(By.id("com.example.petwithlove:id/btn_pswlogin")).click();
//        Thread.sleep(2000);
//        Assert.assertTrue(driver.findElement(By.id("com.example.petwithlove:id/ib_pet_foster")).isDisplayed(),"出错了");
//    }
}
